//
//  CMDBSearchUserParam.swift
//  CMDB
//
//  Created by 王磊 on 17/4/13.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBSearchUserParam: CMDBBasicParamBean {
    
    var condition: String = ""
    
    var ageSort: String = ""
    
    var worksCountSort: String = ""
    
    var enterYearSort: String = ""
    
    var entityTags: String {
        
        return CMDBSearchUserTempParam.castStringArrToString(searchUserTempParam.entityTags)
    }
    
    var languages: String {
        
        return ""
    }
    
    var area: String = ""
    
    var enterYears: String = ""
    
    var passport: String = ""
    
    var ages: String = ""
    
    var searchUserTempParam: CMDBSearchUserTempParam = CMDBSearchUserTempParam()
}
extension CMDBSearchUserParam {
    
    override func URLString() -> String {
        
        return CMDB_Http_Formal_Domain + "/app/search/\(server_Version)/searchUser?"
    }
}
class CMDBSearchUserTempParam: NSObject {
    
    var entityTags: Array<String> = []
    
    var languages: Array<String> = []
}
extension CMDBSearchUserTempParam {
    
    static func castStringArrToString(arr: Array<String>) -> String {
        
        let mutable = NSMutableArray()
        
        _ = arr.map({
            
            mutable.addObject($0)
            
        })
        
        let jsonData = try? NSJSONSerialization.dataWithJSONObject(mutable, options: .PrettyPrinted)
        
        guard let jsonTemp = jsonData else {
            
            return ""
        }
        let jsonStr = String(data: jsonTemp,encoding: NSUTF8StringEncoding)
        
        return jsonStr!
    }
}
